<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改内容管理')" />
    <th:block th:include="include :: select2-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-article-edit" th:object="${article}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label">名称：</label>
                <div class="col-sm-8">
                    <input name="name" th:field="*{name}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">作者：</label>
                <div class="col-sm-8">
                    <input name="author" th:field="*{author}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">标签：</label>
                <div class="col-sm-8">
                    <select id="tags" class="form-control select2-multiple" multiple>
                        <option th:each="tag:${tags}" th:value="${tag.tagId}" th:text="${tag.name}" th:selected="${tag.flag}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">模板：</label>
                <div class="col-sm-8">
                    <select name="template" class="form-control m-b" th:with="type=${@dict.getType('wenyanwen_article_template')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{template}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">内容：</label>
                <div class="col-sm-8">
                    <textarea name="content" class="form-control" th:field="*{content}"  rows="10"></textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">摘要：</label>
                <div class="col-sm-8">
                    <textarea name="zhaiyao" class="form-control" th:field="*{zhaiyao}"  rows="3"></textarea>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">注解：</label>
                <div class="col-sm-8">
                    <textarea name="zhujie" class="form-control" th:field="*{zhujie}"  rows="10"></textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">译文：</label>
                <div class="col-sm-8">
                    <textarea name="yiwen" class="form-control" th:field="*{yiwen}"  rows="10"></textarea>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">赏析：</label>
                <div class="col-sm-8">
                    <textarea name="shangxi" class="form-control" th:field="*{shangxi}"  rows="10"></textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">音频：</label>
                <div class="col-sm-8">
                    <input name="voiceUrl" th:field="*{voiceUrl}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">朝代：</label>
                <div class="col-sm-8">
                    <input name="chaodai" th:field="*{chaodai}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">分类：</label>
                <div class="col-sm-8">
                    <input name="category" th:field="*{category}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">序号：</label>
                <div class="col-sm-8">
                    <input name="seq" th:field="*{seq}" class="form-control" type="text">
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: select2-js" />
    <script type="text/javascript">
        var prefix = ctx + "wenyanwen/article";
        $("#form-article-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {

                let data = $('#form-article-edit').serializeArray()
                let tags = $.form.selectSelects("tags")
                data.push({"name": "tags", "value": tags});
                $.operate.save(prefix + "/edit", data);
            }
        }

        $(function() {
            $('#tags').select2({
                placeholder:"请选择标签",
                allowClear: true
            });
        })

    </script>
</body>
</html>